<?php

namespace App\Exceptions;

use Exception;

class CommonException extends Exception
{
    //异常处理API数据返回
    public $message =array(
        500002 => '最近一次同步时间格式不正确！',
        500003 => 'sql语句错误',
    );
    public function __construct($code)
    {
        parent::__construct($this->message[$code], $code);
    }

    /**
     * 报告异常
     *
     * @return void
     */
    public function report()
    {
        // dd(111);
    }

    /**
     * 转换异常为 HTTP 响应
     *
     * @param  \Illuminate\Http\Request
     * @return \Illuminate\Http\Response
     */
    public function render()
    {
        return response()->json([
            'code' => $this->getCode(),
            'message' => $this->getMessage(),
        ]);
    }

}
